//
//  WebInfo_GetUnreadCount.m
//  EpointFrame5
//
//  Created by 李亚春 on 14-2-25.
//  Copyright (c) 2014年 Epoint. All rights reserved.
//

#import "WebInfo_GetUnreadCount.h"

@implementation WebInfo_GetUnreadCount

-(void)execute
{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *ValidateData = [EpointBizTools getToken];
    NSString *url = self.getMobileOAWebserviceURL;
    NSString *wsNamespace = NSLocalizedString(@"Epoint_DNet_WS_NameSpace", @"");
    NSString *userguid = [userDefaults objectForKey:Epoint_User_UserGuid];
    NSString *categoryguid = [params objectForKey:@"categoryguid"];
    
    
    NSString *ym = [EpointDateUtils convertDate2FormatStr:[NSDate date] format:@"YYYY-MM"];
    NSString *firstDay = [NSString stringWithFormat:@"%@-01",ym];
    
    NSString *lastDay = [NSString stringWithFormat:@"%@-%i",ym,[EpointDateUtils getNumberOfDaysOneMonth:[NSDate date]]];
    
    NSString *ParasXml = @"<![CDATA[<?xml version=\"1.0\" encoding=\"gb2312\"?><paras><UserGuid>%@</UserGuid><CategoryGuid>%@</CategoryGuid><FromDateTime>%@</FromDateTime><ToDateTime>%@</ToDateTime></paras>]]>";
    
    ParasXml = [NSString stringWithFormat:ParasXml,userguid,categoryguid,firstDay,lastDay];
    
    //请求接口
    EpointWebServiceUtil *ws = [[EpointWebServiceUtil alloc]initWithUrl:url namespace:wsNamespace method:@"WebInfo_GetUnreadCount"];
    [ws addParameterForString:@"ValidateData" value:ValidateData];
    [ws addParameterForString:@"ParasXml" value:ParasXml];
    NSString *bs =  ws.start;
    NSMutableArray *result = [self validateXMLWS2:bs];
//    NSString *msg = [result objectAtIndex:1];
    if ([[result objectAtIndex:0]isEqualToString:@"1"]) {
        NSArray *arr = [NSArray arrayWithObjects:categoryguid,[EpointStringUtil getXMLFormatedAttribute:bs :@"UnreadCount"], nil];
        [self exeSuccessWithData:arr];
    }
}

@end
